package org.gwu.seuss.server;

import java.io.IOException;
import java.net.ServerSocket;

public class SeussServer {

	protected ServerSocket listener;
	protected int port;

	public SeussServer(ServerSocket listener, int port) {
		this.listener = listener;
		this.port = port;
	}

	public void start() throws IOException {
		System.out.println("Server has started on port " + port);
		try {
			while (true) {
				new ServerSideSocket(listener.accept()).start();
			}
		} finally {
			listener.close();
		}
	}

	public ServerSocket getListener() {
		return listener;
	}

	public void setListener(ServerSocket listener) {
		this.listener = listener;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

}
